<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">

    <title>Dynamic Table</title>

    <!--dynamic table-->
    <link href="/public/js/advanced-datatable/css/demo_page.css" rel="stylesheet" />
    <link href="/public/js/advanced-datatable/css/demo_table.css" rel="stylesheet" />
    <link rel="stylesheet" href="/public/js/data-tables/DT_bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="/public/js/DataTables-1.10.18/datatables.min.css"/>

    <!--icheck-->
    <link href="/public/js/iCheck/skins/minimal/minimal.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/minimal/red.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/minimal/green.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/minimal/blue.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/minimal/yellow.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/minimal/purple.css" rel="stylesheet">

    <link href="/public/js/iCheck/skins/square/square.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/square/red.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/square/green.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/square/blue.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/square/yellow.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/square/purple.css" rel="stylesheet">

    <link href="/public/js/iCheck/skins/flat/grey.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/flat/red.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/flat/green.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/flat/blue.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/flat/yellow.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/flat/purple.css" rel="stylesheet">


    <?php $this->load->view('library/header');?>
</head>

<body class="sticky-header">

<section>

    <?php $this->load->view('library/left');?>

    <!-- main content start-->
    <div class="main-content" >

        <?php $this->load->view('library/top');?>

        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                产品列表
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">Dashboard</a>
                </li>
                <li>
                    <a href="#">Data Tables</a>
                </li>
                <li class="active"> Dynamic Table </li>
            </ul>
        </div>
        <!-- page heading end-->

        <!--body wrapper start-->
        <div class="wrapper">
            <div class="row">
                <div class="col-sm-12">
                    <?php $this->load->view('library/search');?>
                    <section class="panel">
                        <div class="panel-body">
                            <div class="slide-toggle">
                                <div class="icheck ">

                                    <?php foreach ($siteweb as $val):?>
                                        <div class="minimal single-row">
                                            <div class="checkbox ">
                                                <input type="checkbox" value="<?php echo $val['val'];?>" <?php echo $val['is_acc'] == 1 ? '' : 'checked';?>>
                                                <label><?php echo $val['val'];?></label>
                                            </div>
                                        </div>
                                    <?php endforeach;?>
                                </div>
                            </div>
                        </div>
                    </section>
                    <section class="panel">
                        <div class="panel-body">
                            <div class="adv-table">
                                <table class="display table table-bordered table-striped" id="dynamic-table">
                                    <thead>
                                    <tr>
                                        <th width="5%" rowspan="2">图片</th>
                                        <th width="6%" rowspan="2">货号</th>
                                        <th colspan="<?php echo $siteweb_is_a;?>">站点销量</th>
                                        <th rowspan="2">总销量</th>
                                    </tr>
                                    <tr>
                                        <?php foreach ($siteweb as $k => $val):?>
                                            <th class="<?php echo $val['val'];?>-title val-c-title <?php echo $param['web_order_by'] == $k ?  'sorting_desc' : '';?>" data-k="<?php echo $param['web_order_by'] == $k ? 0 : $k;?>" <?php echo $val['is_acc'] ? 'style="display: none;"' : '';?>><?php echo $val['val'];?></th>
                                        <?php endforeach;?>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php foreach ($goods_list as $item): ?>
                                        <tr class="gradeX">
                                            <td><img style="width: 60px;" src="<?php echo $item['original_img'];?>" /></td>
                                            <td class="center hidden-phone">
                                                <?php echo $item['goods_sn'];?><br />
                                                <?php //echo $item['color'] . "/" . $item['size'];?>
                                            </td>
                                            <?php foreach ($siteweb as $ke => $val):?>
                                                <td class="<?php echo $val['val'];?>-cont" <?php echo $val['is_acc'] ? 'style="display: none;"' : '';?> ><?php echo $item['web_g_number'][$ke]['web_goods_number'];?></td>
                                            <?php endforeach;?>
                                            <td><?php echo intval($item['or_goods_number']);?></td>
                                        </tr>
                                    <?php endforeach;?>
                                    </tbody>
                                </table>
                            </div>
                            <div class="row-fluid">
                                <td class="hidden-phone">
                                    <a style="height: 30px;width: 103px;" class="btn btn-xs btn-info thisURL" href="<?php echo base_url("Product/salegoods_excel?goods_name=".$_GET['goods_name'].'&'.'cate_name='.$_GET['cate_name'].'&'.'order_time_start='.$_GET['order_time_start'].'&'.'order_time_end='.$_GET['order_time_end'].'&'.'goods_time_start='.$_GET['goods_time_start'].'&'.'goods_time_end='.$_GET['goods_time_end'].'&'.'in_time_start='.$_GET['in_time_start'].'&'.'in_time_end='.$_GET['in_time_end'].'&'.'siteweb='.$_GET['siteweb']);?>"><span style="font-size: 17px;">EXCEL导出</span></a>
                                    <select class="excel_psge" name="excel_psge">
                                        <option value="1">1</option>
                                        <option value="2">2</option>
                                        <option value="3">3</option>
                                        <option value="4">4</option>
                                        <option value="5">5</option>
                                        <option value="6">6</option>
                                        <option value="7">7</option>
                                        <option value="8">8</option>
                                        <option value="9">9</option>
                                        <option value="10">10</option>
                                    </select>
                                </td>
                                <div class="span6">
                                    <div class="dataTables_paginate paging_bootstrap pagination">
                                        <ul>
                                            <?php echo $pages;?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </div>
        <!--body wrapper end-->

        <!--footer section start-->
        <footer>
            2014 &copy; AdminEx by
        </footer>
        <!--footer section end-->

        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">采购数据</h4>
                    </div>

                    <div class="modal-body row">

                    </div>

                </div>
            </div>
        </div>
        <!-- modal -->

    </div>
    <!-- main content end-->
</section>

<?php $this->load->view('library/footer');?>

<script type="text/javascript" src="/public/js/DataTables-1.10.18/datatables.min.js"></script>
<!--icheck -->
<script src="/public/js/iCheck/jquery.icheck.js"></script>
<script src="/public/js/icheck-init.js"></script>
<script src="/public/js/jquery.cookies.js"></script>
<script type="text/javascript">
    $(".excel_psge").change(function(){
        var excel_psge = $('.excel_psge').val();
        var href = $('.thisURL').attr('href');
        var url = href + '&page='+excel_psge;
        $('.thisURL').attr('href',url);
    })
    $(function () {
        $(".icheck input").on('ifChanged', function(event){
            var ischecked = $(this).attr('checked');

            var isthnum = Number($('.table thead th:eq(2)').attr('colspan'));

            var val = $(this).val();

            if (ischecked) {
                $('.table thead th:eq(2)').attr('colspan', isthnum + 1);
                $.cookie(val, 0, { expires: 7, path: '/' });
                $('.' + val + '-title').show();
                $('.' + val + '-cont').show();
            } else {
                $('.table thead th:eq(2)').attr('colspan', isthnum - 1);
                $.cookie(val, 1, { expires: 7, path: '/' });
                $('.' + val + '-title').hide();
                $('.' + val + '-cont').hide();
            }
        });

    });

    $('.val-c-title').click(function () {
        var k = $(this).attr('data-k');
        $.cookie('order_sort', k, { expires: 7, path: '/' });

        location.reload();
    });


    $('.mymodal').click(function () {

        var id = $(this).attr('data-id');
        var sale_time_end = $(this).attr('data-end-time');
        var sale_time_tart = $(this).attr('data-st-time');

        $.get('<?php echo base_url('product/ajax_sales');?>'+'?pg_id='+id+'&sale_time_end='+sale_time_end+'&sale_time_start='+sale_time_tart, function (data) {
            $('#myModal .modal-body').html(data);
        }, 'html');
    });

    //设置cookie
    function setCookie(cname, cvalue, exdays) {
        var d = new Date();
        d.setTime(d.getTime() + (exdays*24*60*60*1000));
        var expires = "expires="+d.toUTCString();
        document.cookie = cname + "=" + cvalue + ";path=/; " + expires;
    }
    //获取cookie
    function getCookie(cname) {
        var name = cname + "=";
        var ca = document.cookie.split(';');
        for(var i=0; i<ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1);
            if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
        }
        return "";
    }
    //清除cookie
    function clearCookie(name) {
        setCookie(name, "", -1);
    }
    function add_cookie(export_goods) {
        var cgoods = getCookie('export_goods');
        if(export_goods.checked){
            setCookie('export_goods', (cgoods ? (cgoods+',') : '')+export_goods.value, 1);
        } else {
            arr_goods = cgoods.split(',');
            for (i in arr_goods) {
                if (arr_goods[i] == export_goods.value) {
                    arr_goods.shift(i,1);
                }
            }
            setCookie('export_goods', arr_goods.join(','), 1);
        }
    }

    $(".import-ajax").on("click", function () {

        var url = $(this).attr('href');
        var goods_sn = $(this).attr('data-sn');

        swal({
            title: goods_sn,
            input: 'select',
            inputOptions: <?php echo $siteweb_json; ?>,
            showCancelButton: true,
            allowOutsideClick: false,
            confirmButtonText: 'Submit',
            inputPlaceholder: '请选择网站',
            inputValidator: function(value) {
                if (!value) {
                    return '未选择任何网站!';
                }
            },
            preConfirm: function preConfirm(value) {
                swal({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });
                return $.post(url, {web_id: value}, function (data) {
                    return data;
                },'json');
            }
        }).then(function (result) {
            if (result.value) {
                var data = result.value;
                swal({
                    type: data.status,
                    title: data.info
                }).then(function(isConfirm) {
                    location.reload();
                });
            }
        });

        return false;
    });
</script>

<!--dynamic table-->
<!--<script type="text/javascript" language="javascript" src="/public/js/advanced-datatable/js/jquery.dataTables.js"></script>-->
<!--<script type="text/javascript" src="/public/js/data-tables/DT_bootstrap.js"></script>-->
<!--dynamic table initialization -->
<!--<script src="/public/js/dynamic_table_init.js"></script>-->

<!--common scripts for all pages-->
<script src="/public/js/scripts.js"></script>

</body>
</html>
